Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flake: add darwin devshell dependency #762

Merged
merged 1 commit into from
Sep 18, 2021
Merged

flake: add darwin devshell dependency #762

merged 1 commit into from
Sep 18, 2021

Conversation

happysalada
Copy link
Contributor

@happysalada happysalada commented Sep 17, 2021

This adds a dependency needed for local builds for darwin. This is pretty straightforward

(from here this is just a description of a weird behavior related to flakes, not related to this PR).

@yusdacra the weirdest thing happened today. Trying to build helix from the flake, I couldn't get some changes that actually work with local compilation.
If you look at the following PR, trying to build it from the flake did not enable syntax highlighting on svelte files (which is what the pr is about). However a local cargo build --release actually works.
I can't explain it. (there is a svelte example on the PR in case you are interested in testing).
(I verified that I was on the right commit)
(this is what the flake.lock contained)

 "helix": {
      "inputs": {
        "flakeCompat": "flakeCompat",
        "nixCargoIntegration": "nixCargoIntegration",
        "nixpkgs": "nixpkgs"
      },
      "locked": {
        "lastModified": 1631837505,
        "narHash": "sha256-DLYYl7K2WTcmCJKxVERZKcVCm+Ayph+hiNgl0VXvdDM=",
        "owner": "happysalada",
        "repo": "helix",
        "rev": "392f0bf13bd5f572a9d5eac406d2d48918ac5e32",
        "type": "github"
      },
      "original": {
        "owner": "happysalada",
        "ref": "add_svelte",
        "repo": "helix",
        "type": "github"
      }
    },

and the flake

    # tools
    helix.url = "github:happysalada/helix/add_svelte";

You can try on the latest master as well. Svelte file syntax highlighting doesn't work, even though on local compilation it does.
Maybe that's just a darwin problem.
I'm not sure how to debug this further. Happy to provide more informations.

(if you think it's not that important, feel free to ignore, happy to let this go, just thought you might be interested)

@yusdacra
Copy link
Contributor

yusdacra commented Sep 17, 2021

I think that issue is because the flake uses a pinned helix repo for working around submodules. The pinned repo gets outdated and the language submodule isnt available. Since the fix is merged into Nix now, we should remove the workaround once it lands on unstable Nix.

@happysalada
Copy link
Contributor Author

it landed a couple of days ago I think

❯ nix --version
nix (Nix) 2.4pre20210908_3c56f62

(that is the latest version)

I wasn't able to build the project without that fix (where submodules are automatically updated).

thanks for the quick feedback.

Let me know also if this PR looks ok to you.

@yusdacra
Copy link
Contributor

Ah, if it landed, we should remove the submodule hack (maybe in this PR?).

About the dependency, if libiconv is required on Darwin to build helix, it should be added to the crate overrides' buildInputs for the helix crate that needs it.

@happysalada
Copy link
Contributor Author

so libiconv is already added as a global dependency for darwin in nixpkgs (basically for every crate as a buildInput).
However this PR here aims at the dev workflow, so helping to run cargo build. That will fail with a missing libiconv. This is why I added it to the devDependencies. It's only required for compilation on dev not with nix.

Let me know if that makes sense or if I misunderstood something.

@happysalada
Copy link
Contributor Author

I've removed the helix version fix.
I think i'm still missing something though, I'm not getting syntax highlighting on my files even with the built version.

@yusdacra
Copy link
Contributor

so libiconv is already added as a global dependency for darwin in nixpkgs (basically for every crate as a buildInput).
However this PR here aims at the dev workflow, so helping to run cargo build. That will fail with a missing libiconv. This is why I added it to the devDependencies. It's only required for compilation on dev not with nix.

Let me know if that makes sense or if I misunderstood something.

Ah I see, yeah it makes sense to put it in dev only. I didn't know that some deps were "hardcoded" in buildRustCrate instead of using defaultCrateOverrides. I pushed a commit to nix-cargo-integration master that should add libiconv to devshell when on darwin, so you should update that and see if it does the job.

@happysalada
Copy link
Contributor Author

Just this one https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/rust/default.nix#L125
it is needed in a lot of crates, so rather than adding to 20 crates, somebody suggested just adding it globally.

What do you think about the commit that removes the fixed helix dependency ?

let me test the latest nix-cargo-integration.

@happysalada
Copy link
Contributor Author

I tested with updated flake inputs and the dev shell is working perfectly.

I removed the commit adding libiconv to the dev dependencies.

Let me know about the version fix removal thing.

@yusdacra
Copy link
Contributor

Hmm, the syntax highlighting is still not working? I guess it might be something else then? Could you also check and see if Protobuf files are highlighted? They also do not highlight for me so I'm wondering if it's the same problem.

@archseer
Copy link
Member

It might not be picking up new submodules? I had to git submodule update after a pull to get any new grammars that are added.

@happysalada
Copy link
Contributor Author

I just checked on a protobuf file with the change included in this PR and yes syntax highlighting is working for a message.proto containing the following

message SearchRequest {
  required string query = 1;
  optional int32 page_number = 2;
  optional int32 result_per_page = 3;
}

@archseer you might be right here, it could be a change not picked up in the submodule. I'm going to read more about submodules and nix.

I think this PR can be merged though.

@archseer archseer merged commit ae4d37d into helix-editor:master Sep 18, 2021
@happysalada happysalada deleted the flake_darwin_fixes branch September 19, 2021 02:18
@happysalada
Copy link
Contributor Author

@yusdacra just a littlle more information on this.
The PR reference enabling submodules for flakes, enables them for self, i.e. flakes that you have downloaded and you are working on.
The syntax still doesn't work for github:owner/repo. Meaning that if you need a particular commit, you need to download the flake locally and refer it by file path. I don't think it's a particular problem personally.
There is work ongoing to make the github:owner/repo syntax. It might take another 3 months before it actually lands.
I was thinking of just adding something in the readme to say that the flake needs to be downloaded locally. Let me know what you think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants